package com.sunwayhorizo.health.platform.security.dao.impl;

import javax.ejb.Stateless;

import org.jboss.seam.annotations.Name;

import com.sunwayhorizo.health.platform.base.BaseManager;
import com.sunwayhorizo.health.platform.security.dao.SecurityAccountRolePermissionDao;

@Stateless
@Name("SecurityAccountRolePermissionDao")
public class SecurityAccountRolePermissionImpl extends BaseManager implements SecurityAccountRolePermissionDao{

	@Override
	public void deleteSecurityRoleByAccountId(String accountId) {
		super.entityManager2.createQuery("delete from SecurityAccountRolePermission sarp where sarp.account.accountId= :accountId and sarp.role.roleId is not null ").setParameter("accountId", accountId).executeUpdate();
		super.flushClear(entityManager2);
	}

	@Override
	public void deleteSecurityPermissionByAccountId(String accountId) {
		super.entityManager2.createQuery("delete from SecurityAccountRolePermission sarp where sarp.account.accountId= :accountId and sarp.permission.permissionId is not null ").setParameter("accountId", accountId).executeUpdate();
		super.flushClear(entityManager2);
	}

	@Override
	public void deleteSecurityAccountRolePermissionByAccountId(String accountId) {
		super.entityManager2.createQuery("delete from SecurityAccountRolePermission sarp where sarp.account.accountId= :accountId ").setParameter("accountId", accountId).executeUpdate();
		super.flushClear(entityManager2);
	}
}